<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<link rel="stylesheet" href="css/lib/bootstrap.min.css" />
	<link rel="stylesheet" href="js/themes/default/easyui.css" />
	<script src="js/jquery-3.3.1.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="js/jquery.easyui.min.1.2.2.js"></script>
	<script src="js/lib/bootstrap.min.js"></script>	
	<style>
		body{
			font-size:12px;
		}
		table,
		th,
		td {
			border: 1px solid #eee;
			border-collapse: collapse;
			padding: 5px;
			position: relative;
			vertical-align: middle !important;
		}	
		table td:nth-child(odd) {
			background-color: #f1f1f1;/*#e2e9ea*/
			width:160px;
		}
		table td:nth-child(even) {
			width:300px;
		}
		table tr:nth-child(even) {
			background-color:#ffffff;
		}
		input{
			margin:0;
		}
	</style>
	<body>
		<div class="">
			<div style="padding:2px 5px 0px 5px;border:1px solid #ccc;margin-bottom:15px;box-shadow:3px 5px 15px">
			<table class="table table-hover">
				<caption><h3 style="margin:0">代理商开户</h3></caption>
				<tbody>
					<tr>
						<th colspan="8" style="font-size:26px;color:#337ab7">代理商基本信息</th>
					</tr>
					<tr>
						<td>代理商全称：</td>
						<td colspan="3">
						<input id="fullname"  placeholder="点击输入" class="form-control" type="text" style="width:280px;display:inline-block"/>
						<span style="color:red">(必填)</span>	
						</td>
						<td>代理商简称：</td>
						<td colspan="3">
						<input id="nickName"  placeholder="点击输入" class="form-control" type="text" style="width:280px;margin;margin:0"/>
						</td>						
					</tr>
					<tr>
						<td>组织机构代码：</td>
						<td colspan="3">
						<input id="origcode"  placeholder="点击输入" type="text" class="form-control" style="width:280px;"/>
						</td>
						<td>工商登记号：</td>
						<td colspan="3">
						<input id="signcode"  placeholder="点击输入" type="text" class="form-control" style="width:280px;"/>
						</td>						
					</tr>
					<tr>
						<td>地址：</td>
						<td colspan="3">
						<select class="form-control" id="caty" style="width:80px;">							
							<option value="">北京</option>
							<option value="">上海</option>
							<option value="">广州</option>
							<option value="">深圳</option>
						</select>
						<input id="address"  placeholder="点击输入" style="width:187px;position:absolute;top:7px;left:101px;" class="form-control" type="text"/>
						</td>
						<td>邮编：</td>
						<td colspan="3">
							<input id="zipcode"  placeholder="点击输入" class="form-control" type="text" style="width:280px;"/>
						</td>						
					</tr>
					<tr>
						<td>联系人姓名：</td>
						<td colspan="3">
							<input id="contactname"  placeholder="点击输入" type="text" class="form-control" style="width:280px;display:inline-block"/>
						<span style="color:red">(必填)</span>	
						</td>
						<td>联系人手机号：</td>
						<td colspan="3">
							<input id="phone"  placeholder="点击输入" type="text" class="form-control" style="width:280px;display:inline-block" required="required"/>
						<span style="color:red">(必填)</span>
						</td>						
					</tr>
					<tr>
						<td>代理商级别：</td>
						<td colspan="8">
							<select id="grade" class="form-control" name="state" label="State:" labelPosition="top" style="width:280px;display:inline-block" required="required">
								<option value="">请选择</option>
								<option value="1">初级代理</option>
								<option value="2">中级代理</option>
								<option value="3">高级代理</option>						
							</select>
							<!-- <input type="text" id="grade" class="form-control" style="width:280px;display:inline-block"> -->
							<span style="color:red">(必填--对应初，中，高等级产品,也可在下级会员等级变更处修改等级)</span>
						</td>
					</tr>
					<tr>
						<td>保证金金额:</td>
						<td colspan="3">
							<input  placeholder="点击输入" type="text" class="form-control" value="0.00" style="width:280px;"/>
						</td>
						<td>加盟费金额：</td>
						<td colspan="3">
							<input  placeholder="点击输入" type="text" class="form-control" value="0.00" style="width:280px;"/>
						</td>						
					</tr>
				</tbody>
			</table>
		</div>
		<!--此功能暂时无用--隐藏-->
		<div style="padding:15px 5px 0px 5px;border:1px solid #ccc;margin-bottom:15px;display:none">
			<table class="table table-hover">				
				<tbody>
					<tr>
						<th colspan="8" style="font-size:26px;color:#337ab7">返利结算账户信息</th>
					</tr>
					<tr>
						<td>开户地:</td>
						<td colspan="3">
							<input  placeholder="点击输入" class="form-control" type="text" style="width:280px;"/>
						</td>
						<td>返利是否开发票:</td>
						<td colspan="3">					
						<label style="padding-right:50px;">
						<input name="Fruit" type="radio" value="" />开发票</label>
						<label>
						<input name="Fruit" type="radio" value="" />不开发票</label>						
						</td>						
					</tr>
					<tr>
						<td>银行名称:</td>
						<td colspan="3">
							<div style="margin-bottom:5px">
							<select class="form-control" name="state" label="State:" labelPosition="top" style="width:280px;">
								<option value="AR">请选择</option>
								<option value="AL">工商银行</option>
								<option value="AK">农业银行</option>
								<option value="AZ">建设银行</option>
								<option value="AR">交通银行</option>
								<option value="CA">招商银行</option>
								<option value="CO">中信银行</option>
								<option value="CT">光大银行</option>
								<option value="DE">北京银行</option>
								<option value="FL">其他银行</option>
							</select>
						</td>
						<td>支行名称:</td>
						<td colspan="3">
							<input  placeholder="点击输入" class="form-control" type="text" style="width:280px;"/>
						</td>						
					</tr>
					<tr>
						<td>开户账号名称:</td>
						<td colspan="3">
							<input  placeholder="点击输入" class="form-control" type="text" style="width:280px;"/>
						</td>
						<td>开户银行账号:</td>
						<td colspan="3">
							<input  placeholder="点击输入" class="form-control" type="text" style="width:280px;"/>
						</td>						
					</tr>
				</tbody>
			</table>
		</div>
		
	<div style="padding:15px 5px 0px 5px;border:1px solid #ccc;margin-bottom:15px;display:none">
			<table class="table table-hover">
				
				<tbody>
					<tr>
						<th colspan="8" style="font-size:26px;color:#337ab7">上级代理信息</th>
					</tr>
					<tr>
						<td>所属销售:</td>
						<td colspan="3">
							<select class="form-control" name="state" label="State:" labelPosition="top" style="width:280px;">
								<option value="">请选择</option>
								<option id="op"></option>								
							</select>							
						</td>
						<td>上级代理:</td>
						<td colspan="3">
							<select id="sel" class="form-control" name="state" label="State:" labelPosition="top" style="width:280px;">
								<option value="">请选择</option>
								<option id="op1"></option>
							</select>							
						</td>						
					</tr>
					<tr>
						<td>合同编号:</td>
						<td colspan="3">
							<input placeholder="点击输入" class="form-control" type="text" style="width:280px;"/>
						</td>
						<td>截止合同有效期：</td>
						<td colspan="3">
							<input class=" form-control" placeholder="点击输入"  class="easyui-datebox" type="date" style="width:280px;">							
						</td>						
					</tr>
				</tbody>
			</table>
		</div>
		
		<div style="padding:15px 5px 0px 5px;border:1px solid #ccc;margin-bottom:15px;box-shadow:3px 5px 15px">
			<table class="table table-hover">			
				<tbody>
					<tr>
						<th colspan="8" style="font-size:26px;color:#337ab7">代理商管理员信息：</th>
					</tr>
					<tr>
						<td>代理商登录账号:</td>
						<td colspan="3"><input placeholder="点击输入" class="form-control" type="text" style="width:280px;" /></td>
						<td>代理商管理员姓名:</td>
						<td colspan="3"><input placeholder="点击输入" class="form-control" type="text" style="width:280px;" /></td>						
					</tr>
					<tr>
						<td>代理商管理员邮箱:</td>
						<td colspan="3">
								<input type="text" placeholder="点击输入" class="form-control" style="width:280px;"/><!--<span style="position: absolute;left:290px;top:15px;">(密码以邮件通知)</span>-->	
						</td>
						<td>上级手机号：</td>
						<td colspan="3">
							<input id="preUserPhone" placeholder="点击输入" class="form-control" type="text" style="width:280px;display:inline-block;" />
							<span style="color:red">(必填)</span>
						</td>						
					</tr>
				</tbody>
			</table>
		</div>
		<div>
			<button type="submit" id="btn" class="btn btn-danger" style="display:block;margin:0 auto">开户</button>
		</div>
		</div>
	</body>
<script>
	$(function(){	
			var brandid = sessionStorage.getItem(key=3);
			var brandname = sessionStorage.getItem(key=100);
			console.log(brandname);
			$('#op').val(brandid);
			$('#op').text(brandname);
			$('#op1').val(brandid);
			$('#op1').text(brandname);
		    $.ajax({
					url:window.baseUrl+'user/thirdlevel/prod/brand/'+brandid,					
					datatype:'json',					
					type:'GET',					
					data:{},									
					success:function(data){
						console.log(data);
						var html = "<option selected='selected' value=''>请选择</option>";
		                var vendorJson = eval(data.result);
		                for(var i=0; i<vendorJson.length; i++){
		                html += "<option value= '"+vendorJson[i].grade+"'>"+vendorJson[i].name+"</option>";
		                }
		                $("#grade").html('').append(html);
					},
					error:function(data){
						console.log('开户失败！')
					}
			})
		$('#btn').click(function(){
					var phone = $('#phone').val();
					var nickName = $('#nickName').val();
					var fullname = $('#fullname').val();
					var origcode = $('#origcode').val();
					var signcode = $('#signcode').val();
					var address =  $('#address').val();
					var caty = $('#caty').find('option:selected').text();
					var contactname= $('#contactname').val();
					var zipcode = $('#zipcode').val();
					var email = $('#email').val();
					var validStatus = $('#validStatus').val();
					var brandId = $('#brandId').val();
					var brandname = sessionStorage.getItem(key=100);
					var grade = $('#grade').val();
					var preUserId = $('#preUserId').val();
					var preUserPhone = $('#preUserPhone').val();
					var data = {
			            phone:phone,
			            nickName:nickName,
			            fullname:fullname,
			            origcode:origcode,
			            signcode:signcode,
			            address:address,
			            contactname:contactname,
			            zipcode:zipcode,
			            city:caty,
			            email:email,
			            validStatus:validStatus,
			            grade:grade,
			            preUserId:preUserId,
			            pre_phone:preUserPhone,
						brand_id:brandid,
						brand_name:brandname
					};
					console.log(data);
					if(phone!="" && grade!="" && preUserPhone!=""){
					$.ajax({
					url:window.baseUrl+'user/openaccount',					
					datatype:'json',					
					type:'POST',					
					data:{
			            phone:phone,
			            nickName:nickName,
			            fullname:fullname,
			            origcode:origcode,
			            signcode:signcode,
			            address:address,
			            contactname:contactname,
			            zipcode:zipcode,
			            city:caty,
			            email:email,
			            validStatus:validStatus,
			            grade:grade,
			            preUserId:preUserId,
			            pre_phone:preUserPhone,
						brand_id:brandid,
						brand_name:brandname

					},					
					success:function(data){
						alert(data.resp_message)
						console.log(data)
						$('#phone').val("");
						$('#nickName').val("");
						$('#fullname').val("");
						$('#origcode').val("");
						$('#signcode').val("");
						$('#address').val("");
						$('#contactname').val("");
					    $('#zipcode').val("");						
						$('#email').val("");
						$('#validStatus').val("");
						$('#brandId').val("");
						$('#brandname').val("");
						$('#grade').val("");
						$('#preUserId').val("");
						$('#preUserPhone').val("");
					},
					error:function(data){
						alert("开户失败！")
						console.log('开户失败！')
					}
			})
					}else{
						alert("请完善基本信息！")
					}
					
				
		})
			
	})
	
</script>
</html>